﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor
{
    /// <summary>
    /// 用于获取最新版的安装包。
    /// </summary>
    class Update
    {
        private static string GetVersionTextFromUrl(string url)
        {
            //url 形如："browser_download_url": "https://gitee.com/lunarsf/Lunar-Markdown-Editor/attach_files/download?i=126257&u=http%3A%2F%2Ffiles.git.oschina.net%2Fgroup1%2FM00%2F03%2F3D%2FPaAvDFq_TJyAWPk6AKUUhnlW4Bo213.exe%3Ftoken%3Da2611927241f46795f6bff25bb6fe9a0%26ts%3D1522533782%26attname%3DLMSetup%20v0.0.5.3.exe"
            //结尾是：LMSetup%20v0.0.5.3.exe
            Regex reg = new Regex(@"(?<=v)\d{1}.\d{1,}.\d{1,}.\d{1,}.exe$");
            var match = reg.Match(url);
            if (match.Success)
            {
                return "LMSetup " + match.Value;
            }

            return "LMSetup " + DateTime.Now.Date.ToShortDateString() + ".exe";
        }
    }
}
